<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{$title}</title>
    <link rel="shortcut icon" href="__STATIC__/src/common/img/cauliflower-small.png" type="image/x-icon" />
    <link rel="stylesheet" type="text/css"  href="__STATIC__/src/common/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css"  href="__STATIC__/src/common/css/common.css" />
</head>
<body>
{include file="common/header"}
<div class="container" style="margin-top: 50px;">
    <div class="row">
        <div class="col-md-3">
            <div class="panel panel-info">
                <div class="panel-heading">
                    <h3 class="panel-title">通知</h3>
                </div>
                <div class="panel-body" style="height: 260px; overflow-y: auto;">
                    <ul class="list-group">
                        {volist name="notifies" id="notify"}
                        <li class="list-group-item">
                            <div>
                                <div><a href='{php} echo url("showNotify?notify=".($notify["notify_id"]*17+79853)) {/php}'>{php} echo mb_strlen($notify["notify_title"]) > 7 ? mb_substr($notify["notify_title"], 0, 7)."......" : $notify["notify_title"]; {/php}</a></div>
                                <div style="color: #AAAAAA;">{$notify.notify_time}</div>
                            </div>
                        </li>
                        {/volist}
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-md-8 col-md-offset-1">
            {if condition="$paperName == ''"}
                <div class="alert alert-warning">
                    监考人还未上传考试试卷，请耐心等待！
                </div>
            {else /}
                <div class="alert alert-waring {$paperAlert}">
                    监考人员还未上传试卷，请耐心等待。
                </div>
                <div class="panel panel-success {$paperInfo}">
                    <div class="panel-heading">
                        <h3 class="panel-title">试卷详情</h3>
                    </div>
                    <div class="panel-body">
                        <span class="label label-info pointer normal-fontSize" title="{$paperName}" data-toggle="tooltip">{$paperName}({$fileSize})</span>
                        <a class="btn btn-primary" style="margin-left: 20px;" href='{:url("downloadPaper?fileName=$paperName&examName=$examName")}'>下载考卷</a>
                    </div>
                </div>
                <div class="panel panel-success">
                    <div class="panel-heading">
                        <h3 class="panel-title">答案上传</h3>
                    </div>
                    <div class="panel-body">
                        <div style="height: 50px">
                            <form action="{:url('uploadAnswerPath')}" method="post" enctype="multipart/form-data">
                                <input type="text" id="answerPath" readonly="readonly" style="position: absolute;width: 150px;left: 30px;"/>
                                <input type="file" name="answer" style="position: absolute; width: 100px; left: 200px; opacity: 0; z-index: 10;" onchange="addFilePath(this)"/>
                                <button type="button" class="btn btn-primary" style="position: absolute; width: 100px; left: 200px;"><span class="glyphicon glyphicon-folder-open img-text"></span>选择</button>
                                <button type="submit" class="btn btn-primary" style="position: absolute; width: 100px; left: 320px;">上传</button>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="panel panel-success">
                    <div class="panel-heading">
                        <h3 class="panel-title">已提交信息</h3>
                    </div>
                    <div class="panel-body">
                        <div>
                            <table class="table">
                                <tr>
                                    <th>上传文件名</th>
                                    <th>上传时间</th>
                                </tr>
                                <tr>
                                    <td>
                                        {$examinee.answerPath}
                                    </td>
                                    <td>
                                        {if condition="$examinee.answerPath == ''"}
                                        {else /}{$examinee.answerTime}
                                        {/if}
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            {/if}
        </div>
    </div>
</div>
<script src="__STATIC__/src/common/js/jquery-3.2.1.js"></script>
<script src="__STATIC__/src/common/js/bootstrap.js"></script>
<script src="__STATIC__/src/common/js/admin.js"></script>
<script src="__STATIC__/src/common/js/teacher.js"></script>
<script>
    $(function() {
        $("[data-toggle='tooltip']").tooltip();
    });
    function addFilePath(obj) {
        $("#answerPath").val(obj.value);
    }
    let Alarm = function (interval, countFunc, endFunc) {
        this.time = interval; //时间
        this.countFunc = countFunc; //计时函数
        this.endFunc = endFunc; //结束函数
        this.flag = 't' + Date.parse(new Date());
    };
    Alarm.prototype.start = function () {
        let self = this;
        self.flag = setInterval(function () {
            if (self.time < 0) {
                clearInterval(self.flag);
                self.endFunc();
                console.log('计时结束');
            } else {

                let minute, hour, day, second;
                day = Math.floor(self.time / 60 / 60 / 24) < 10 ? '0' + Math.floor(self.time / 60 / 60 / 24) : Math.floor(self.time / 60 / 60 / 24);
                hour = Math.floor(self.time / 60 / 60 % 24) < 10 ? '0' + Math.floor(self.time / 60 / 60 % 24) : Math.floor(self.time / 60 / 60 % 24);
                minute = Math.floor(self.time / 60 % 60) < 10 ? '0' + Math.floor(self.time / 60 % 60) : Math.floor(self.time / 60 % 60);
                second = Math.floor(self.time % 60) < 10 ? '0' + Math.floor(self.time % 60) : Math.floor(self.time % 60);
                //倒计时执行函数
                self.countFunc(second, minute, hour, day);
                self.time--;

            }
        }, 1000);
    };
    let timers = document.getElementsByName('timer');
    let timerInterval = new Array(timers.length);
    for(let i = 0; i < timers.length; i++) {
        timerInterval[i] = new Alarm(parseInt(timers[i].getAttribute('class')),function (second,minute,hour,day) {
            timers[i].innerHTML = day + "天" + hour + "小时" + minute + "分钟" + second + "秒";
        },function () {
            timers[i].innerHTML = "<a class='btn btn-primary bigger-fontSize'>进入考试</a>";
        });
        timerInterval[i].start();
    }
</script>
</body>
</html>